<template>
    <div>
      <el-dropdown style="position: absolute; top: 8px; right: 10px;">
          <span class="el-dropdown-link">
              <div class="block" style="font-size: 16px;color:aliceblue;">
                <el-avatar :size="40" :src="txjpg" />
                <span class="account">{{account}}</span>
                <i class="el-icon-arrow-down el-icon--right"></i>
              </div>
          </span>
          <template #dropdown>
              <el-dropdown-menu>
                  <el-dropdown-item @click="gotoMyInfo">修改资料</el-dropdown-item>
                  <el-dropdown-item divided>修改密码</el-dropdown-item>
                  <el-dropdown-item divided @click="outLogins">退出登录</el-dropdown-item>
              </el-dropdown-menu>
          </template>
      </el-dropdown>
  </div>
</template>
<script lang="ts" setup>
import txjpg from '@/assets/0002.jpg';
import router from '@/router';
import { accountStore,tokenStore,loginStore } from '@/store/modules/user'
import { outLogin } from '@/api/Login'
import {ref} from "vue";

let name =ref(accountStore().account)

onMounted(()=>{
    account.value=accountStore().account;
})
let account =ref();
const outLogins = () => {
    const account:string=accountStore().account
    outLogin({account:account})
    accountStore().setAccount('')
    tokenStore().setToken('')
    loginStore().setLoginStatus(false)
    router.replace("/")
}

const gotoMyInfo= () => {
  router.push("/layout/myinfo")
}
</script>
<style scoped>
.example-showcase .el-dropdown-link {
    cursor: pointer;
    color: var(--el-color-primary);
    display: flex;
    align-items: center;
}
.account{
  position: relative;
  left: 5px;
  bottom: 15px;
  color: black;
  font-size: 20px;
  margin-left: 10px;
}
</style>